<html>
<head><meta charset="utf-8"><title>Type inference progress · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Type.20inference.20progress.html">Type inference progress</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="159228558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Type%20inference%20progress/near/159228558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Type.20inference.20progress.html#159228558">(Feb 23 2019 at 13:01)</a>:</h4>
<p>We are now at just about 80% of expressions in RA itself having a complete type inferred <span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span> :</p>
<div class="codehilite"><pre><span></span>Database loaded, 21 roots
Crates in this dir: 27
Total modules found: 230
Total declarations: 3760
Total functions: 2480
Total expressions: 49160
Expressions of unknown type: 8156 (16%)
Expressions of partially unknown type: 2432 (4%)
</pre></div>


<p>Of course there'll be some that are wrong (I can think of a few things), but I think it's nice progress :) For rustc, we're at 69%.</p>



<a name="159228629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Type%20inference%20progress/near/159228629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Type.20inference.20progress.html#159228629">(Feb 23 2019 at 13:03)</a>:</h4>
<p><span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span></p>



<a name="159228635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Type%20inference%20progress/near/159228635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Type.20inference.20progress.html#159228635">(Feb 23 2019 at 13:03)</a>:</h4>
<p>That means that one doesn't need traits 80% of the time, right? :)</p>



<a name="159228995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Type%20inference%20progress/near/159228995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Type.20inference.20progress.html#159228995">(Feb 23 2019 at 13:14)</a>:</h4>
<p>Seems that way ;)</p>
<p>(Though there's quite a few things in the code model API that we should probably put into traits...)</p>



<a name="159229010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Type%20inference%20progress/near/159229010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Type.20inference.20progress.html#159229010">(Feb 23 2019 at 13:15)</a>:</h4>
<p>oh yeah. We have like a dozen of <code>fn module(&amp;self)</code> :D</p>



<a name="159229017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Type%20inference%20progress/near/159229017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Type.20inference.20progress.html#159229017">(Feb 23 2019 at 13:16)</a>:</h4>
<p>We do use quite a bit of traits for ast though</p>



<a name="159317908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Type%20inference%20progress/near/159317908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vipentti <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Type.20inference.20progress.html#159317908">(Feb 25 2019 at 07:13)</a>:</h4>
<p>Hey! I'm currently working on <a href="https://github.com/rust-analyzer/rust-analyzer/issues/887" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/887">rust-analyzer#887</a> to add Const / Static inference. I've gotten to a point where the inference works when the const is defined in the module scope (outside <code>fn test()</code>) but failing when the const is defined inside the function. I noticed that <a href="https://github.com/rust-analyzer/rust-analyzer/blob/7ffff9c74caae108db53366e3b90857b7c405c6c/crates/ra_hir/src/expr.rs#L931-L938" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/blob/7ffff9c74caae108db53366e3b90857b7c405c6c/crates/ra_hir/src/expr.rs#L931-L938">https://github.com/rust-analyzer/rust-analyzer/blob/7ffff9c74caae108db53366e3b90857b7c405c6c/crates/ra_hir/src/expr.rs#L931-L938</a> has TODO regarding consts etc. Can I attempt to add support for block defined consts together with <a href="https://github.com/rust-analyzer/rust-analyzer/issues/887" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/887">rust-analyzer#887</a> or should that be done in a separate PR ?</p>



<a name="159319531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Type%20inference%20progress/near/159319531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Type.20inference.20progress.html#159319531">(Feb 25 2019 at 07:57)</a>:</h4>
<p>I would keep that separate, it's almost completely independent of constants: Block-level items need to be handled during import resolution (in <code>nameres.rs</code>). The TODO you're linking to is about handling the bodies of constants, i.e. what I wrote at the end of <a href="https://github.com/rust-analyzer/rust-analyzer/issues/887" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/887">rust-analyzer#887</a> :)</p>



<a name="159319655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Type%20inference%20progress/near/159319655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vipentti <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Type.20inference.20progress.html#159319655">(Feb 25 2019 at 08:00)</a>:</h4>
<p>Ah yes, thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>